package com.gmstu.defaults.dao;

import com.gmstu.defaults.entity.Member;
import com.gmstu.springorm.framework.BaseDaoSupport;
import com.gmstu.springorm.framework.QueryRule;

import javax.sql.DataSource;
import java.util.List;

/**
 * @author John.zhang
 * @version Id: MemberDao, v 1.0 2020/9/1 17:40 ZhiYong Exp $
 */
public class MemberDao extends BaseDaoSupport<Member, Long> {
    @Override
    protected String getPKColumn() {
        return "id";
    }

    @Override
    protected void setDataSource(DataSource dataSource) {
        super.setDataSourceRead(dataSource);
        super.setDataSourceWrite(dataSource);
    }

    public List<Member> select() throws Exception {
        QueryRule queryRule = QueryRule.getInstance();
        queryRule.andLike("name", "John%");
        queryRule.andEqual("age", 18);
        queryRule.addDescOrder("age");
        return super.select(queryRule);
    }
}
